package pro4;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/Ans4/DeleteProductServlet")
public class DeleteProductServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        ProductDAO dao = null;
        try {
            dao = new ProductDAO();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            dao.deleteProduct(id);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        response.sendRedirect("product_management.jsp");
    }
}
